var WS = function () {
  // var ws = new WebSocket("wss://" + socket_url);
//   var ws = new WebSocket("wss://" + socket_url + "/wss:8282");// 线上版本
  var ws = new WebSocket("wss://" + socket_url + ":8282"); //0427修改
  var _this = this;

  // 打开链接
  _this.open = function (callback) {
    ws.onopen = function () {
      // Web Socket 已连接上，使用 send() 方法发送数据
      _log('socket 已连接')
      if (typeof callback == 'function') {
        callback();
      }
    };
  }

  // 错误
  _this.error = function () {
    ws.onerror = function (e) {
      _log(e);
      _log(JSON.stringify(e));
    }
  }

  // 发送数据
  _this.send = function (msg) {
    ws.send(msg);
  }

  // 接收数据
  _this.get = function (callback) {
    ws.onmessage = function (evt) {
      var received_msg = evt.data;
      if (typeof callback == 'function') {
        callback(received_msg);
      }
    };
  }
  // socket 已关闭
  _this.close = function (callback) {
    ws.onclose = function () {
      // if(!myuserid){
      //     _alert('获取用户信息失败，请重新登录', function(){
      //         _login();
      //     })
      //     return;
      // }
    };
  }
  _this.error();
  _this.close();
}